package ip.ejb.entity;
/***********************************************************************
 * Module:  MovieSubtitlesBean.java
 * Author:  mojsilo
 * Purpose: Defines the Class MovieSubtitlesBean
 ***********************************************************************/

import ip.ejb.sequence.SequenceSessionLocal;
import ip.ejb.sequence.SequenceSessionLocalHome;

import java.sql.Date;
import java.util.Collection;

import javax.ejb.CreateException;
import javax.ejb.EntityContext;
import javax.naming.InitialContext;

/**
 * @ejb.bean 
 * 	cmp-version="2.x"
 *  name="MovieSubtitles"
 *  type="CMP"
 *  jndi-name="ip/ejb/entity/MovieSubtitles"
 *  local-jndi-name="ip/ejb/entity/MovieSubtitlesLocal"
 *  reentrant="false"
 *  
 * @ejb.finder
 *   signature="java.util.Collection findAll()"
 *   query="SELECT OBJECT(a) FROM MovieSubtitles a"
 *   method-intf="LocalHome"
 *  
 * @ejb.persistence
 * 	table-name="movie_subtitles"
 * 
 * @ejb.transaction
 * 	type="Required"
 * 
 * @jboss.table-name
 * 	table-name="movie_subtitles"
 * 
 * @jboss.create-table
 * 	create="true"
 * 
 * @jboss.remove-table
 * 	remove="false"
 */
public abstract class MovieSubtitlesBean implements javax.ejb.EntityBean
{
	private EntityContext ejbContext = null;
	private SequenceSessionLocal sequenceSession = null;

	/**
	 * @ejb.create-method view-type="both"
	 */
	public MovieSubtitlesPK ejbCreate(LanguageLocal language, MovieLocal movie) throws CreateException {

		return null;
	}   

	public void ejbPostCreate(LanguageLocal language,  MovieLocal movie){
		setLanguage(language);
		setMovie(movie);
	}

	public void setEntityContext(EntityContext ctx) throws javax.ejb.EJBException
	{
		SequenceSessionLocalHome home = null;
		Object obj = null;
		this.ejbContext = ctx;
		try {
			obj = (new InitialContext()).lookup("ejb/util/SequenceSessionLocal");
			home = (SequenceSessionLocalHome) obj;
			sequenceSession = home.create();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	public void unsetEntityContext() throws javax.ejb.EJBException
	{
		this.ejbContext = null;
		try {
			sequenceSession.remove();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	/**
	 * @ejb.persistence column-name="language_id"
	 * @ejb.interface-method view-type="both"
	 * @ejb.pk-field
	 * @jboss.jdbc-type type="INTEGER"
	 * @jboss.sql-type  type="INTEGER"
	 */
	public abstract int getLanguageId();

	/**
	 * @ejb.interface-method view-type="local"
	 */
	public abstract void setLanguageId(int languageId);
	
	/**
	 * @ejb.persistence column-name="movie_id"
	 * @ejb.interface-method view-type="both"
	 * @ejb.pk-field
	 * @jboss.jdbc-type type="INTEGER"
	 * @jboss.sql-type  type="INTEGER"
	 */
	public abstract int getMovieId();

	/**
	 * @ejb.interface-method view-type="local"
	 */
	public abstract void setMovieId(int movieId);
	
	/**
	 * @ejb.interface-method view-type="local"
	 * @ejb.relation
	 *   name="Movie-Subtitles"
	 *   role-name="Subtitles-of-Movie"
	 *   cascade-delete="yes"
	 * @jboss.relation
	 *   fk-constraint="true"
	 *   fk-column="movieId"
	 *   related-pk-field="movieId"
	 */
	public abstract MovieLocal getMovie();
	/**
	 * @ejb.interface-method view-type="local"
	 */
	public abstract void setMovie(MovieLocal movie);
	
	/**
	 * @ejb.interface-method view-type="local"
	 * @ejb.relation
	 *   name="Language-Subtitle"
	 *   role-name="Subtitles-Language"
	 *   cascade-delete="yes"
	 * @jboss.relation
	 *   fk-constraint="true"
	 *   fk-column="languageId"
	 *   related-pk-field="languageId" 
	 */
	public abstract LanguageLocal getLanguage();
	/**
	 * @ejb.interface-method view-type="local"
	 */
	public abstract void setLanguage(LanguageLocal language);

	public void ejbActivate() throws javax.ejb.EJBException{}
	public void ejbLoad() throws javax.ejb.EJBException{}
	public void ejbPassivate() throws javax.ejb.EJBException{}
	public void ejbRemove() throws javax.ejb.RemoveException, javax.ejb.EJBException{}
	public void ejbStore() throws javax.ejb.EJBException{}

}